package liangtWorkSpace.Observer.base;

import java.util.Observable;

/**
 * @ClassName WeatherData
 * @Description : 使用JDK自带的Observable
 * @Author : LiangT
 * @Date : 2020/6/19 11:18
 */
public class WeatherData extends Observable {
    private float pressure;
    private float humidity;
    private float temperature;

    public WeatherData() {
    }

    /**
     * 调用父类中的setChanged
     * 调用父类中的推送功法
     */
    public void measurementsChanged(){
        setChanged();
        notifyObservers();
    }


    /**
     * 初始化参数
     * @param pressure
     * @param humidity
     * @param temperature
     */
    public void setMeasurement(float pressure, float humidity, float temperature) {
        this.pressure = pressure;
        this.humidity = humidity;
        this.temperature = temperature;
        measurementsChanged();
    }

    public float getPressure() {
        return pressure;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getTemperature() {
        return temperature;
    }
}
